package com.firewolf.word;

import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.firewolf.utils.FreeMarkerUtil;

import freemarker.template.Template;
import freemarker.template.TemplateException;
/**
 * 数据类型
 * @author liuxing
 *
 */
public class Word {
	public static void main(String[] args) throws TemplateException, IOException {
		//数据模型
		Map<String, Object> root = new HashMap<>();
		List<Danxuan> dList = new ArrayList<>();
		dList.add(new Danxuan("以下哪个数字是小数？","A. 3","B. 40","C. 3.4","D. abc"));
		dList.add(new Danxuan("以下哪个是男人","A. 宋江","B. 扈三娘","C. 潘金莲","D. 张小妹"));
		dList.add(new Danxuan("以下哪一个是水果","A. 香蕉","B. 土豆","C. 番茄","D. 萝卜"));
		root.put("danxuan", dList);
		
		List<String> pList = new ArrayList<>();
		pList.add("中国的煤都是()");
		pList.add("中国的铁都是()");
		root.put("duoxuan", pList);
		
		//图片信息
		FileInputStream fs = new FileInputStream("01.jpg");
		byte[] image = new byte[fs.available()];
		fs.read(image);
		root.put("image", Base64.getEncoder().encodeToString(image));
		
		Template tl = FreeMarkerUtil.getTemplate("ceshi2.ftl");
		
		Writer w = new FileWriter("html/aaa.doc");// 把数据显示到控制台
		tl.process(root, w);
		w.flush();
	}
}
